/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gameutil;

import com.jme3.bounding.BoundingBox;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

/**
 *
 * @author Lcn
 */
public class GameUtil {

    public static Geometry findGeom(Spatial spatial, String name) {
        if (spatial instanceof Node) {
            Node node = (Node) spatial;
            for (int i = 0; i < node.getQuantity(); i++) {
                Spatial child = node.getChild(i);
                Geometry result = findGeom(child, name);
                if (result != null) {
                    return result;
                }
            }
        } else if (spatial instanceof Geometry) {
            if (spatial.getName().startsWith(name)) {
                return (Geometry) spatial;
            }
        }
        return null;
    }
    
    public static Vector3f processPos(int barrierCount, Vector3f startPos, BoundingBox worldBound) {
//        BoundingBox worldBound = (BoundingBox) spa.getWorldBound();
        Vector3f extent = worldBound.getExtent(null);
        Vector3f vec = new Vector3f(startPos.x + barrierCount * extent.x * 2, 0, 0);
//        spa.setLocalTranslation(startPos.x + barrierCount * extent.x / 4, 0, 0);
        return vec;
    }    
    
}
